//
//  YKClientListHeaderView.m
//  YunKang
//
//  Created by leoking870 on 2017/9/26.
//  Copyright © 2017年 leoking870. All rights reserved.
//

#import "YKClientListHeaderView.h"

@implementation YKClientListHeaderView

- (instancetype)initWithTitles:(NSArray *)titles
                       weights:(NSArray<NSNumber *> *)weights{
    return [self initWithTitles:titles weights:weights spaceing:4 leading:13 trailing:13];
}
- (instancetype)initWithTitles:(NSArray *)titles
                       weights:(NSArray<NSNumber *> *)weights
                      spaceing:(CGFloat)spacing
                       leading:(CGFloat)leading
                       trailing:(CGFloat)trailing{
    if (self = [super init]) {
        self.backgroundColor = [UIColor tf_colorWithHexString:@"#32C7D9"];
        for (int i = 0; i < titles.count; ++i) {
            UILabel* clientCodeLabel = [[UILabel alloc]init];
            clientCodeLabel.tf_weight = [weights[i] integerValue];
            clientCodeLabel.text = titles[i];
            clientCodeLabel.textAlignment = NSTextAlignmentCenter;
            clientCodeLabel.textColor = [UIColor whiteColor];
            [self addSubview:clientCodeLabel];
        }
        [self.subviews mas_alignWeightlyAlongAxis:MASAxisTypeHorizontal fixedSpace:@(spacing) leadingTo:self.mas_leading leadSpace:leading trailingTo:self.mas_trailing tailSpace:trailing];
        [self.subviews mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.mas_top).offset(12);
            make.bottom.equalTo(self.mas_bottom).offset(-12);
        }];
    }
    return self;
}
- (void)setTextFont:(UIFont *)textFont {
    [self.subviews makeObjectsPerformSelector:@selector(setFont:) withObject:textFont];
}
- (void)setTextColor:(UIColor *)textColor {
    [self.subviews makeObjectsPerformSelector:@selector(setTextColor:) withObject:textColor];
}

- (UIColor *)textColor {
    UILabel* label = self.subviews.firstObject;
    return label.textColor;
}

- (UIFont *)textFont {
    UILabel* label = self.subviews.firstObject;
    return label.font;
}

@end
